﻿using Pay.DTO;
using Pay.IService;
using Pay.TO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;

namespace Pay.Token.Controllers
{
    /// <summary>
    /// 商家
    /// </summary>
    [RoutePrefix("business")]
    public class MerchIntroduceController : BaseController
    {
        private IMerchIntroduceService _iMerchIntroduceService;
        private ISoupTaskService _iSoupTaskService;
        public MerchIntroduceController(IMerchIntroduceService iMerchIntroduceService, ISoupTaskService iSoupTaskService)
        {
            _iMerchIntroduceService = iMerchIntroduceService;
            _iSoupTaskService = iSoupTaskService;
        }

        /// <summary>
        /// 获得首页商家介绍列表
        /// </summary>
        /// <returns></returns>
        [Route("get_index_business"), HttpGet,AllowAnonymous]
        public ResultMessage<List<merch_dto>> GetIndexMerchIntroduceList()
        {
            var result = _iMerchIntroduceService.GetAppIndexMerchIntroduceList();
            return ResultToJson.Json(result);
        }

        /// <summary>
        /// 获得通知商家介绍分页列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [Route("get_business"), HttpGet,AllowAnonymous]
        public ResultMessage<PagedResult<merch_dto>> GetMerchIntroducePageList([FromUri]PageQuery query)
        {
            var list = _iMerchIntroduceService.GetAppMerchIntroducePageList(query);
            var result = new PagedResult<merch_dto>(list.rows, list.total_result, list.page, list.size);
            return ResultToJson.Json(result);
        }
        /// <summary>
        /// 获得商家介绍详情
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [Route("get_business_detail"), HttpGet]
        public ResultMessage<merch_detail_dto> GetMerchIntroduce([FromUri]merch_introduce_query model)
        {
            var result = _iMerchIntroduceService.AppGetMerchIntroduce(model.id, UserId);
            return ResultToJson.Json(result);
        }
        /// <summary>
        /// 用户领取商家介绍马力值
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [Route("receive_business"), HttpPost]
        public async Task<ResultMessage<bool>> GetMerchInstroduceSoupValue([FromBody]merch_introduce_query model)
        {
            var result= await _iSoupTaskService.TaskRecive(UserId, ETaskType.MerchIntroduce,model.id);
            return ResultToJson.Json(result);
        }


    }
}
